
import java.util.TreeMap;

class UserTable {

    private TreeMap map = new TreeMap();
    private TreeMap map2 = new TreeMap();
    private int i = 0, k = 0;

    public synchronized USer get(String name) {
        return (USer) map.get(name);
    }

    public synchronized USer getDeleted(String nameD) {
        return (USer) map2.get(nameD);
    }

    public synchronized boolean add(String nameA, USer userA) {
        if (map.containsKey(nameA)) {

            return false;
        } else {
            map.put(nameA, userA);
            i++;
            return true;
        }
    }

    public synchronized boolean AddusrDeleted(String nameAD, USer userAD) {
        if (map2.containsKey(nameAD)) {
            return false;
        } else {
            map2.put(nameAD, userAD);
            k++;
            return true;
        }
    }

    public synchronized void delete(String Dname) {

        map.remove(Dname);
        i--;
    }

    public synchronized void DuserDeleted(String DDname) {

        map2.remove(DDname);
        k--;
    }

    public synchronized boolean KitchenOn(String Kname) {
        if (!map.containsKey(Kname)) {
            return false;
        } else {
            return true;
        }

    }

    public synchronized String[] clientsdisconnected() {
        Object[] ov = map2.keySet().toArray();
        String[] sv = new String[ov.length];
        for (int g = 0; g < ov.length; g++) {
            sv[g] = (String) ov[g];
        }
        return sv;
    }

    public synchronized String[] clients() {
        Object[] ov = map.keySet().toArray();
        String[] sv = new String[ov.length];
        for (int m = 0; m < ov.length; m++) {
            sv[m] = (String) ov[m];
        }
        return sv;
    }

    public synchronized int clientsOn() {
        if (i < 0) {
            i = 0;
        }
        return i;
    }

    public synchronized int clientsOff() {
        if (k < 0) {
            k = 0;
        }
        return k;
    }
}
